Remove infrastructure for the old custom build command
authorAlex Crichton <alex@alexcrichton.com>
Mon, 19 Jan 2015 22:27:51 +0000 (14:27 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 19 Jan 2015 23:48:06 +0000 (15:48 -0800)
This aspect of the manifest has been deprecated for quite some time now, and
this commit purges the support entirely.

14 files changed:
src/cargo/core/manifest.rs
src/cargo/ops/cargo_rustc/custom_build.rs
src/cargo/ops/cargo_rustc/fingerprint.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/util/toml.rs
tests/test_cargo_bench.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_compile_old_custom_build.rs [deleted file]
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_cross_compile.rs
tests/test_cargo_doc.rs
tests/test_cargo_test.rs
tests/tests.rs

index 836919de5f9bf7baca476f3357ee2a4ddb7d56f9..e45dfe219b19e41092956e63623d50f7e9313090 100644 (file)
@@ -15,7 +15,6 @@ pub struct Manifest {
     targets: Vec<Target>,
     target_dir: Path,
     doc_dir: Path,
-    build: Vec<String>,         // TODO: deprecated, remove
     links: Option<String>,
     warnings: Vec<String>,
     exclude: Vec<String>,
@@ -52,7 +51,6 @@ pub struct SerializedManifest {
     targets: Vec<Target>,
     target_dir: String,
     doc_dir: String,
-    build: Option<Vec<String>>,     // TODO: deprecated, remove
 }
 
 impl Encodable for Manifest {
@@ -66,8 +64,6 @@ impl Encodable for Manifest {
             targets: self.targets.clone(),
             target_dir: self.target_dir.display().to_string(),
             doc_dir: self.doc_dir.display().to_string(),
-            // TODO: deprecated, remove
-            build: if self.build.len() == 0 { None } else { Some(self.build.clone()) },
         }.encode(s)
     }
 }
@@ -388,7 +384,6 @@ impl Encodable for Target {
 impl Manifest {
     pub fn new(summary: Summary, targets: Vec<Target>,
                target_dir: Path, doc_dir: Path,
-               build: Vec<String>,
                exclude: Vec<String>,
                include: Vec<String>,
                links: Option<String>,
@@ -398,7 +393,6 @@ impl Manifest {
             targets: targets,
             target_dir: target_dir,
             doc_dir: doc_dir,
-            build: build,     // TODO: deprecated, remove
             warnings: Vec::new(),
             exclude: exclude,
             include: include,
@@ -439,10 +433,6 @@ impl Manifest {
         &self.doc_dir
     }
 
-    pub fn get_build(&self) -> &[String] {
-        self.build.as_slice()
-    }
-
     pub fn get_links(&self) -> Option<&str> {
         self.links.as_ref().map(|s| s.as_slice())
     }
index 72560226ae77929d346545718c85ce9c1b408a35..54b633d58eb5c56b45e3ff228c2bc00a28d05161 100644 (file)
@@ -179,7 +179,7 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
     //
     // Also note that a fresh build command needs to
     let (freshness, dirty, fresh) =
-            try!(fingerprint::prepare_build_cmd(cx, pkg, Some(target)));
+            try!(fingerprint::prepare_build_cmd(cx, pkg, kind, Some(target)));
     let dirty = Work::new(move |tx| {
         try!(work(tx.clone()));
         dirty.call(tx)
index a707679658fc8df4311113c32f048005d7d65344..7f765a354d4a3c7634ca64d4d2a0c834634183b7 100644 (file)
@@ -124,17 +124,14 @@ pub fn prepare_target(cx: &mut Context, pkg: &Package, target: &Target,
 ///
 /// The currently implemented solution is option (1), although it is planned to
 /// migrate to option (2) in the near future.
-pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package,
+pub fn prepare_build_cmd(cx: &mut Context, pkg: &Package, kind: Kind,
                          target: Option<&Target>) -> CargoResult<Preparation> {
-    let _p = profile::start(format!("fingerprint build cmd: {}",
-                                    pkg.get_package_id()));
-
-    // TODO: this should not explicitly pass Kind::Target
-    let kind = Kind::Target;
-
-    if pkg.get_manifest().get_build().len() == 0 && target.is_none() {
+    if target.is_none() {
         return Ok((Fresh, Work::noop(), Work::noop()));
     }
+
+    let _p = profile::start(format!("fingerprint build cmd: {}",
+                                    pkg.get_package_id()));
     let new = dir(cx, pkg, kind);
     let loc = new.join("build");
     cx.layout(pkg, kind).proxy().whitelist(&loc);
index a61fddb365b467d37a6d4c392dac0b368fe8f733..a5d56339813057d613b2e5df61e8768af0bb5389 100644 (file)
@@ -1,14 +1,12 @@
 use std::collections::{HashSet, HashMap};
 use std::dynamic_lib::DynamicLibrary;
-use std::ffi::CString;
-use std::io::USER_RWX;
 use std::io::fs::{self, PathExtensions};
 use std::path;
 use std::sync::Arc;
 
 use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve};
 use util::{self, CargoResult, human, caused_human};
-use util::{Config, internal, ChainError, Fresh, profile, join_paths, Human};
+use util::{Config, internal, ChainError, Fresh, profile, join_paths};
 
 use self::job::{Job, Work};
 use self::job_queue::{JobQueue, Stage};
@@ -320,39 +318,8 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
         }
     }
 
-    if targets.iter().any(|t| t.get_profile().is_custom_build()) {
-        // New custom build system
-        jobs.enqueue(pkg, Stage::BuildCustomBuild, build_custom);
-        jobs.enqueue(pkg, Stage::RunCustomBuild, run_custom);
-
-    } else {
-        // Old custom build system
-        // OLD-BUILD: to-remove
-        let mut build_cmds = Vec::new();
-        for (i, build_cmd) in pkg.get_manifest().get_build().iter().enumerate() {
-            let work = try!(compile_custom_old(pkg, build_cmd.as_slice(), cx, i == 0));
-            build_cmds.push(work);
-        }
-        let (freshness, dirty, fresh) =
-            try!(fingerprint::prepare_build_cmd(cx, pkg, None));
-        let desc = match build_cmds.len() {
-            0 => String::new(),
-            1 => pkg.get_manifest().get_build()[0].to_string(),
-            _ => format!("custom build commands"),
-        };
-        let dirty = Work::new(move |desc_tx| {
-            if desc.len() > 0 {
-                desc_tx.send(desc).ok();
-            }
-            for cmd in build_cmds.into_iter() {
-                try!(cmd.call(desc_tx.clone()))
-            }
-            dirty.call(desc_tx)
-        });
-        jobs.enqueue(pkg, Stage::BuildCustomBuild, vec![]);
-        jobs.enqueue(pkg, Stage::RunCustomBuild, vec![(job(dirty, fresh), freshness)]);
-    }
-
+    jobs.enqueue(pkg, Stage::BuildCustomBuild, build_custom);
+    jobs.enqueue(pkg, Stage::RunCustomBuild, run_custom);
     jobs.enqueue(pkg, Stage::Libraries, libs);
     jobs.enqueue(pkg, Stage::Binaries, bins);
     jobs.enqueue(pkg, Stage::BinaryTests, bin_tests);
@@ -360,81 +327,6 @@ fn compile<'a, 'b>(targets: &[&'a Target], pkg: &'a Package,
     Ok(())
 }
 
-// OLD-BUILD: to-remove
-fn compile_custom_old(pkg: &Package, cmd: &str,
-                      cx: &Context, first: bool) -> CargoResult<Work> {
-    let root = cx.get_package(cx.resolve.root());
-    let profile = root.get_manifest().get_targets().iter()
-                      .find(|target| target.get_profile().get_env() == cx.env())
-                      .map(|target| target.get_profile());
-    let profile = match profile {
-        Some(profile) => profile,
-        None => return Err(internal(format!("no profile for {}", cx.env())))
-    };
-    // Just need a target which isn't a custom build command
-    let target = &pkg.get_targets()[0];
-    assert!(!target.get_profile().is_custom_build());
-
-    // TODO: this needs to be smarter about splitting
-    let mut cmd = cmd.split(' ');
-    // TODO: this shouldn't explicitly pass `Kind::Target` for dest/deps_dir, we
-    //       may be building a C lib for a plugin
-    let layout = cx.layout(pkg, Kind::Target);
-    let output = layout.native(pkg);
-    let exe = CString::from_slice(cmd.next().unwrap().as_bytes());
-    let mut p = try!(process(CommandType::Host(exe), pkg, target, cx))
-                     .env("OUT_DIR", Some(&output))
-                     .env("DEPS_DIR", Some(&output))
-                     .env("TARGET", Some(cx.target_triple()))
-                     .env("DEBUG", Some(profile.get_debug().to_string()))
-                     .env("OPT_LEVEL", Some(profile.get_opt_level().to_string()))
-                     .env("LTO", Some(profile.get_lto().to_string()))
-                     .env("PROFILE", Some(profile.get_env()));
-    for arg in cmd {
-        p = p.arg(arg);
-    }
-    match cx.resolve.features(pkg.get_package_id()) {
-        Some(features) => {
-            for feat in features.iter() {
-                p = p.env(format!("CARGO_FEATURE_{}",
-                                  envify(feat.as_slice())).as_slice(),
-                          Some("1"));
-            }
-        }
-        None => {}
-    }
-
-
-    for &(pkg, _) in cx.dep_targets(pkg, target).iter() {
-        let name: String = pkg.get_name().chars().map(|c| {
-            match c {
-                '-' => '_',
-                c => c.to_uppercase(),
-            }
-        }).collect();
-        p = p.env(format!("DEP_{}_OUT_DIR", name).as_slice(),
-                  Some(&layout.native(pkg)));
-    }
-    let pkg = pkg.to_string();
-
-    let exec_engine = cx.exec_engine.clone();
-
-    Ok(Work::new(move |desc_tx| {
-        desc_tx.send(p.to_string()).ok();
-        if first && !output.exists() {
-            try!(fs::mkdir(&output, USER_RWX).chain_error(|| {
-                internal("failed to create output directory for build command")
-            }))
-        }
-        try!(exec_engine.exec_with_output(p).map(|_| ()).map_err(|mut e| {
-            e.desc = format!("Failed to run custom build command for `{}`\n{}",
-                             pkg, e.desc);
-            Human(e)
-        }));
-        Ok(())
-    }))
-}
-
 fn rustc(package: &Package, target: &Target,
          cx: &mut Context, req: Platform)
          -> CargoResult<Vec<(Work, Kind)> >{
@@ -766,19 +658,6 @@ fn build_deps_args(mut cmd: CommandPrototype, target: &Target, package: &Package
         None
     });
 
-    // Traverse the entire dependency graph looking for -L paths to pass for
-    // native dependencies.
-    // OLD-BUILD: to-remove
-    let mut dirs = Vec::new();
-    each_dep(package, cx, |pkg| {
-        if pkg.get_manifest().get_build().len() > 0 {
-            dirs.push(layout.native(pkg));
-        }
-    });
-    for dir in dirs.into_iter() {
-        cmd = cmd.arg("-L").arg(format!("native={}", dir.display()));
-    }
-
     for &(pkg, target) in cx.dep_targets(package, target).iter() {
         cmd = try!(link_to(cmd, pkg, target, cx, kind));
     }
@@ -821,7 +700,7 @@ fn build_deps_args(mut cmd: CommandPrototype, target: &Target, package: &Package
     }
 }
 
-pub fn process(cmd: CommandType, pkg: &Package, target: &Target,
+pub fn process(cmd: CommandType, pkg: &Package, _target: &Target,
                cx: &Context) -> CargoResult<CommandPrototype> {
     // When invoking a tool, we need the *host* deps directory in the dynamic
     // library search path for plugins and such which have dynamic dependencies.
@@ -829,20 +708,6 @@ pub fn process(cmd: CommandType, pkg: &Package, target: &Target,
     let mut search_path = DynamicLibrary::search_path();
     search_path.push(layout.deps().clone());
 
-    // OLD-BUILD: to-remove
-    // Also be sure to pick up any native build directories required by plugins
-    // or their dependencies
-    let mut native_search_paths = HashSet::new();
-    for &(dep, target) in cx.dep_targets(pkg, target).iter() {
-        if !target.get_profile().is_for_host() { continue }
-        each_dep(dep, cx, |dep| {
-            if dep.get_manifest().get_build().len() > 0 {
-                native_search_paths.insert(layout.native(dep));
-            }
-        });
-    }
-    search_path.extend(native_search_paths.into_iter());
-
     // We want to use the same environment and such as normal processes, but we
     // want to override the dylib search path with the one we just calculated.
     let search_path = try!(join_paths(search_path.as_slice(),
index ca072252b6ad27bd97e15dc56f57368d047bcd1d..9e51f09c8e0efb73b651110c83ab7b265fe2b3d6 100644 (file)
@@ -253,7 +253,7 @@ pub struct TomlProject {
     name: String,
     version: TomlVersion,
     authors: Vec<String>,
-    build: Option<BuildCommand>,       // TODO: `String` instead
+    build: Option<String>,
     links: Option<String>,
     exclude: Option<Vec<String>>,
     include: Option<Vec<String>>,
@@ -269,13 +269,6 @@ pub struct TomlProject {
     repository: Option<String>,
 }
 
-// TODO: deprecated, remove
-#[derive(RustcDecodable)]
-pub enum BuildCommand {
-    Single(String),
-    Multiple(Vec<String>)
-}
-
 pub struct TomlVersion {
     version: semver::Version,
 }
@@ -449,17 +442,7 @@ impl TomlManifest {
         };
 
         // processing the custom build script
-        let (new_build, old_build) = match project.build {
-            Some(BuildCommand::Single(ref cmd)) => {
-                if cmd.as_slice().ends_with(".rs") && layout.root.join(cmd.as_slice()).exists() {
-                    (Some(Path::new(cmd.as_slice())), Vec::new())
-                } else {
-                    (None, vec!(cmd.clone()))
-                }
-            },
-            Some(BuildCommand::Multiple(ref cmd)) => (None, cmd.clone()),
-            None => (None, Vec::new())
-        };
+        let new_build = project.build.clone().map(Path::new);
 
         // Get targets
         let profiles = self.profile.clone().unwrap_or(Default::default());
@@ -509,8 +492,6 @@ impl TomlManifest {
         let exclude = project.exclude.clone().unwrap_or(Vec::new());
         let include = project.include.clone().unwrap_or(Vec::new());
 
-        let has_old_build = old_build.len() >= 1;
-
         let summary = try!(Summary::new(pkgid, deps,
                                         self.features.clone()
                                             .unwrap_or(HashMap::new())));
@@ -529,7 +510,6 @@ impl TomlManifest {
                                          targets,
                                          layout.root.join("target"),
                                          layout.root.join("doc"),
-                                         old_build,
                                          exclude,
                                          include,
                                          project.links.clone(),
@@ -538,14 +518,6 @@ impl TomlManifest {
             manifest.add_warning(format!("the [[lib]] section has been \
                                           deprecated in favor of [lib]"));
         }
-        if has_old_build {
-            manifest.add_warning(format!("warning: an arbitrary build command \
-                                          has now been deprecated."));
-            manifest.add_warning(format!("         It has been replaced by custom \
-                                                   build scripts."));
-            manifest.add_warning(format!("         For more information, see \
-                                          http://doc.crates.io/build-script.html"));
-        }
         if project.license_file.is_some() && project.license.is_some() {
             manifest.add_warning(format!("warning: only one of `license` or \
                                                    `license-file` is necessary"));
index 70c75fdd1982566695d6958af4eac10d030457b5..3108b0bc22cb628999ccba39bb23ba025b614d74 100644 (file)
@@ -750,8 +750,9 @@ test!(bench_twice_with_build_cmd {
             name = "foo"
             version = "0.0.1"
             authors = []
-            build = 'true'
+            build = "build.rs"
         "#)
+        .file("build.rs", "fn main() {}")
         .file("src/lib.rs", "
             extern crate test;
             #[bench]
index 6b08da08f135b3916c485c507988af67e4d789d9..43e7343c0f4a39ace5b1e95888acaa1f71143d7b 100644 (file)
@@ -1252,9 +1252,10 @@ test!(freshness_ignores_excluded {
             name = "foo"
             version = "0.0.0"
             authors = []
-            build = "true"
+            build = "build.rs"
             exclude = ["src/b*.rs"]
         "#)
+        .file("build.rs", "fn main() {}")
         .file("src/lib.rs", "pub fn bar() -> int { 1 }");
     foo.build();
     foo.root().move_into_the_past().unwrap();
@@ -1280,37 +1281,27 @@ test!(freshness_ignores_excluded {
 });
 
 test!(rebuild_preserves_out_dir {
-    let mut build = project("builder");
-    build = build
+    let foo = project("foo")
         .file("Cargo.toml", r#"
             [package]
-            name = "builder"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
+            name = "foo"
+            version = "0.0.0"
+            authors = []
+            build = 'build.rs'
         "#)
-        .file("src/main.rs", r#"
+        .file("build.rs", r#"
             use std::os;
             use std::io::File;
 
-            fn main() {{
+            fn main() {
                 let path = Path::new(os::getenv("OUT_DIR").unwrap()).join("foo");
                 if os::getenv("FIRST").is_some() {
                     File::create(&path).unwrap();
                 } else {
                     File::create(&path).unwrap();
                 }
-            }}
-        "#);
-    assert_that(build.cargo_process("build"), execs().with_status(0));
-
-    let foo = project("foo")
-        .file("Cargo.toml", format!(r#"
-            [package]
-            name = "foo"
-            version = "0.0.0"
-            authors = []
-            build = '{}'
-        "#, build.bin("builder").display()).as_slice())
+            }
+        "#)
         .file("src/lib.rs", "pub fn bar() -> int { 1 }");
     foo.build();
     foo.root().move_into_the_past().unwrap();
index 422f43990c5df290e26fd9522851809dcaa32f74..7555c94a8702a22b9d804a4265733368f2f713e0 100644 (file)
@@ -1087,8 +1087,9 @@ test!(git_build_cmd_freshness {
             name = "foo"
             version = "0.0.0"
             authors = []
-            build = "true"
+            build = "build.rs"
         "#)
+        .file("build.rs", "fn main() {}")
         .file("src/lib.rs", "pub fn bar() -> int { 1 }")
         .file(".gitignore", "
             src/bar.rs
@@ -1175,11 +1176,12 @@ test!(git_repo_changing_no_rebuild {
             name = "p1"
             version = "0.5.0"
             authors = []
-            build = 'true'
+            build = 'build.rs'
             [dependencies.bar]
             git = '{}'
         "#, bar.url()).as_slice())
-        .file("src/main.rs", "fn main() {}");
+        .file("src/main.rs", "fn main() {}")
+        .file("build.rs", "fn main() {}");
     p1.build();
     p1.root().move_into_the_past().unwrap();
     assert_that(p1.process(cargo_dir().join("cargo")).arg("build"),
@@ -1247,7 +1249,7 @@ test!(git_dep_build_cmd {
             name = "bar"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "cp src/bar.rs.in src/bar.rs"
+            build = "build.rs"
 
             [lib]
 
@@ -1256,6 +1258,13 @@ test!(git_dep_build_cmd {
         .file("bar/src/bar.rs.in", r#"
             pub fn gimme() -> int { 0 }
         "#)
+        .file("bar/build.rs", r#"
+            use std::io::fs;
+            fn main() {
+                fs::copy(&Path::new("src/bar.rs.in"),
+                         &Path::new("src/bar.rs")).unwrap();
+            }
+        "#)
     }).unwrap();
 
     p.root().join("bar").move_into_the_past().unwrap();
diff --git a/tests/test_cargo_compile_old_custom_build.rs b/tests/test_cargo_compile_old_custom_build.rs
deleted file mode 100644 (file)
index 0855548..0000000
+++ /dev/null
@@ -1,408 +0,0 @@
-use std::path;
-
-use support::{project, execs, cargo_dir};
-use hamcrest::{assert_that};
-
-fn setup() {
-}
-
-test!(old_custom_build {
-    let mut build = project("builder");
-    build = build
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]] name = "foo"
-        "#)
-        .file("src/foo.rs", r#"
-            fn main() { println!("Hello!"); }
-        "#);
-    assert_that(build.cargo_process("build"),
-                execs().with_status(0));
-
-
-    let mut p = project("foo");
-    p = p
-        .file("Cargo.toml", format!(r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = '{}'
-
-            [[bin]] name = "foo"
-        "#, build.bin("foo").display()))
-        .file("src/foo.rs", r#"
-            fn main() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(0)
-                       .with_stdout(format!("   Compiling foo v0.5.0 ({})\n",
-                                            p.url()))
-                       .with_stderr("warning: [..] deprecated.\n\
-                                              [..]\n\
-                                              [..]"));
-});
-
-test!(old_custom_multiple_build {
-    let mut build1 = project("builder1");
-    build1 = build1
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]] name = "foo"
-        "#)
-        .file("src/foo.rs", r#"
-            fn main() {
-                let args = ::std::os::args();
-                assert_eq!(args[1], "hello".to_string());
-                assert_eq!(args[2], "world".to_string());
-            }
-        "#);
-    assert_that(build1.cargo_process("build"),
-                execs().with_status(0));
-
-    let mut build2 = project("builder2");
-    build2 = build2
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "bar"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]] name = "bar"
-        "#)
-        .file("src/bar.rs", r#"
-            fn main() {
-                let args = ::std::os::args();
-                assert_eq!(args[1], "cargo".to_string());
-            }
-        "#);
-    assert_that(build2.cargo_process("build"),
-                execs().with_status(0));
-
-    let mut p = project("foo");
-    p = p
-        .file("Cargo.toml", format!(r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = [ '{} hello world', '{} cargo' ]
-
-            [[bin]] name = "foo"
-        "#, build1.bin("foo").display(), build2.bin("bar").display()))
-        .file("src/foo.rs", r#"
-            fn main() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(0)
-                       .with_stdout(format!("   Compiling foo v0.5.0 ({})\n",
-                                            p.url())));
-});
-
-test!(old_custom_build_failure {
-    let mut build = project("builder");
-    build = build
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]]
-            name = "foo"
-        "#)
-        .file("src/foo.rs", r#"
-            fn main() { panic!("nope") }
-        "#);
-    assert_that(build.cargo_process("build"), execs().with_status(0));
-
-
-    let mut p = project("foo");
-    p = p
-        .file("Cargo.toml", format!(r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = '{}'
-
-            [[bin]]
-            name = "foo"
-        "#, build.bin("foo").display()))
-        .file("src/foo.rs", r#"
-            fn main() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr(format!("\
-warning: an arbitrary build command has now been deprecated.
-         [..]
-         [..]
-Failed to run custom build command for `foo v0.5.0 ({dir})`
-Process didn't exit successfully: `{}` (status=101)\n\
---- stderr\n\
-thread '<main>' panicked at 'nope', {filename}:2\n\
-\n\
-", build.bin("foo").display(), filename = format!("src{}foo.rs", path::SEP),
-   dir = p.url())));
-});
-
-test!(old_custom_second_build_failure {
-    let mut build1 = project("builder1");
-    build1 = build1
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]] name = "foo"
-        "#)
-        .file("src/foo.rs", r#"
-            fn main() { println!("Hello!"); }
-        "#);
-    assert_that(build1.cargo_process("build"),
-                execs().with_status(0));
-
-    let mut build2 = project("builder2");
-    build2 = build2
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "bar"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]]
-            name = "bar"
-        "#)
-        .file("src/bar.rs", r#"
-            fn main() { panic!("nope") }
-        "#);
-    assert_that(build2.cargo_process("build"), execs().with_status(0));
-
-
-    let mut p = project("foo");
-    p = p
-        .file("Cargo.toml", format!(r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = [ '{}', '{}' ]
-
-            [[bin]]
-            name = "foo"
-        "#, build1.bin("foo").display(), build2.bin("bar").display()))
-        .file("src/foo.rs", r#"
-            fn main() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(101).with_stderr(format!("\
-warning: an arbitrary build command has now been deprecated.
-         [..]
-         [..]
-Failed to run custom build command for `foo v0.5.0 ({dir})`
-Process didn't exit successfully: `{}` (status=101)\n\
---- stderr\n\
-thread '<main>' panicked at 'nope', {filename}:2\n\
-\n\
-", build2.bin("bar").display(), filename = format!("src{}bar.rs", path::SEP),
-   dir = p.url())));
-});
-
-test!(old_custom_build_env_vars {
-    let bar = project("bar")
-        .file("Cargo.toml", r#"
-            [package]
-            name = "bar-bar"
-            version = "0.0.1"
-            authors = []
-            build = "true"
-        "#)
-        .file("src/lib.rs", "");
-    bar.build();
-
-    let mut p = project("foo");
-    let mut build = project("builder");
-    build = build
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [features]
-            foo = []
-
-            [[bin]]
-            name = "foo"
-        "#)
-        .file("src/foo.rs", format!(r#"
-            use std::os;
-            use std::io::fs::PathExtensions;
-            fn main() {{
-                let _ncpus = os::getenv("NUM_JOBS").unwrap();
-                let _feat = os::getenv("CARGO_FEATURE_FOO").unwrap();
-                let debug = os::getenv("DEBUG").unwrap();
-                assert_eq!(debug.as_slice(), "true");
-
-                let opt = os::getenv("OPT_LEVEL").unwrap();
-                assert_eq!(opt.as_slice(), "0");
-
-                let opt = os::getenv("PROFILE").unwrap();
-                assert_eq!(opt.as_slice(), "compile");
-
-                let out = os::getenv("OUT_DIR").unwrap();
-                assert!(out.as_slice().starts_with(r"{0}"));
-                assert!(Path::new(out).is_dir());
-
-                let out = os::getenv("DEP_BAR_BAR_OUT_DIR").unwrap();
-                assert!(out.as_slice().starts_with(r"{0}"));
-                assert!(Path::new(out).is_dir());
-
-                let out = os::getenv("CARGO_MANIFEST_DIR").unwrap();
-                let p1 = Path::new(out);
-                let p2 = os::make_absolute(&Path::new(file!()).dir_path().dir_path()).unwrap();
-                assert!(p1 == p2, "{{}} != {{}}", p1.display(), p2.display());
-            }}
-        "#,
-        p.root().join("target").join("native").display()));
-    assert_that(build.cargo_process("build").arg("--features").arg("foo"),
-                execs().with_status(0));
-
-
-    p = p
-        .file("Cargo.toml", format!(r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = '{}'
-
-            [features]
-            foo = []
-
-            [[bin]]
-            name = "foo"
-
-            [dependencies.bar-bar]
-            path = '{}'
-        "#, build.bin("foo").display(), bar.root().display()))
-        .file("src/foo.rs", r#"
-            fn main() {}
-        "#);
-    assert_that(p.cargo_process("build").arg("--features").arg("foo"),
-                execs().with_status(0));
-});
-
-test!(old_custom_build_in_dependency {
-    let mut p = project("foo");
-    let mut build = project("builder");
-    build = build
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]]
-            name = "foo"
-        "#)
-        .file("src/foo.rs", format!(r#"
-            use std::os;
-            fn main() {{
-                assert!(os::getenv("OUT_DIR").unwrap().as_slice()
-                           .starts_with(r"{}"));
-            }}
-        "#,
-        p.root().join("target/native/bar-").display()));
-    assert_that(build.cargo_process("build"), execs().with_status(0));
-
-
-    p = p
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]]
-            name = "foo"
-            [dependencies.bar]
-            path = "bar"
-        "#)
-        .file("src/foo.rs", r#"
-            extern crate bar;
-            fn main() { bar::bar() }
-        "#)
-        .file("bar/Cargo.toml", format!(r#"
-            [project]
-
-            name = "bar"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-            build = '{}'
-        "#, build.bin("foo").display()))
-        .file("bar/src/lib.rs", r#"
-            pub fn bar() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(0));
-});
-
-// tests that custom build in dep can be built twice in a row - issue 227
-test!(old_custom_build_in_dependency_twice {
-    let p = project("foo")
-        .file("Cargo.toml", r#"
-            [project]
-
-            name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
-
-            [[bin]]
-            name = "foo"
-            [dependencies.bar]
-            path = "./bar"
-            "#)
-        .file("src/foo.rs", r#"
-            extern crate bar;
-            fn main() { bar::bar() }
-            "#)
-        .file("bar/Cargo.toml", format!(r#"
-            [project]
-
-            name = "bar"
-            version = "0.0.1"
-            authors = ["wycats@example.com"]
-            build = '{}'
-        "#, "echo test"))
-        .file("bar/src/lib.rs", r#"
-            pub fn bar() {}
-        "#);
-    assert_that(p.cargo_process("build"),
-                execs().with_status(0));
-    assert_that(p.process(cargo_dir().join("cargo")).arg("build"),
-                execs().with_status(0));
-});
index 3e6a75294df2bcab67b45f89d8e96289b90d9ead..7ca80b5ddb3bf9109b4678ae0c69c4a25b6bad46 100644 (file)
@@ -658,12 +658,19 @@ test!(path_dep_build_cmd {
             name = "bar"
             version = "0.5.0"
             authors = ["wycats@example.com"]
-            build = "cp src/bar.rs.in src/bar.rs"
+            build = "build.rs"
 
             [lib]
 
             name = "bar"
         "#)
+        .file("bar/build.rs", r#"
+            use std::io::fs;
+            fn main() {
+                fs::copy(&Path::new("src/bar.rs.in"),
+                         &Path::new("src/bar.rs")).unwrap();
+            }
+        "#)
         .file("bar/src/bar.rs.in", r#"
             pub fn gimme() -> int { 0 }
         "#);
index 668a81ab690889a1cd3938f38b36baf863884953..a4d2ed024e7c9640572d8ce62f2604327bd19f6a 100644 (file)
@@ -34,30 +34,19 @@ fn alternate() -> &'static str {
 test!(simple_cross {
     if disabled() { return }
 
-    let mut build = project("builder");
-    build = build
+    let p = project("foo")
         .file("Cargo.toml", r#"
-            [project]
+            [package]
             name = "foo"
-            version = "0.5.0"
-            authors = ["wycats@example.com"]
+            version = "0.0.0"
+            authors = []
+            build = "build.rs"
         "#)
-        .file("src/main.rs", format!(r#"
+        .file("build.rs", format!(r#"
             fn main() {{
                 assert_eq!(std::os::getenv("TARGET").unwrap().as_slice(), "{}");
             }}
-        "#, alternate()).as_slice());
-    assert_that(build.cargo_process("build"),
-                execs().with_status(0));
-
-    let p = project("foo")
-        .file("Cargo.toml", format!(r#"
-            [package]
-            name = "foo"
-            version = "0.0.0"
-            authors = []
-            build = '{}'
-        "#, build.bin("foo").display()))
+        "#, alternate()).as_slice())
         .file("src/main.rs", r#"
             use std::os;
             fn main() {
index e26f46ebfb98c854d3043296fac20de81d04f09d..3612b03125521c60db78df15d998813291df71b3 100644 (file)
@@ -12,8 +12,9 @@ test!(simple {
             name = "foo"
             version = "0.0.1"
             authors = []
-            build = 'true'
+            build = "build.rs"
         "#)
+        .file("build.rs", "fn main() {}")
         .file("src/lib.rs", r#"
             pub fn foo() {}
         "#);
index 877454357ad5df4b998a8b916d6cd1c51c83e05c..f9478626f9e73c954dfd962ab3c72f6dd60594fc 100644 (file)
@@ -755,8 +755,9 @@ test!(test_twice_with_build_cmd {
             name = "foo"
             version = "0.0.1"
             authors = []
-            build = 'true'
+            build = "build.rs"
         "#)
+        .file("build.rs", "fn main() {}")
         .file("src/lib.rs", "
             #[test]
             fn foo() {}
index 96a4049aedee4ba1531f060c39a850336f4e1f79..c4e5f356d343d8622dcea07a7d3969d40c91d187 100644 (file)
@@ -34,7 +34,6 @@ mod test_cargo_clean;
 mod test_cargo_compile;
 mod test_cargo_compile_custom_build;
 mod test_cargo_compile_git_deps;
-mod test_cargo_compile_old_custom_build;
 mod test_cargo_compile_path_deps;
 mod test_cargo_compile_plugins;
 mod test_cargo_cross_compile;